package org.wu.framework.lazy.orm.database.sql.expand.database.persistence.factory;

import org.wu.framework.lazy.orm.core.config.LazyOperationAttribute;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.method.LazyOperationMethod;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.method.LazyOperationParameter;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.method.ddl.*;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.method.dml.*;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.method.dql.*;
import org.wu.framework.lazy.orm.database.sql.expand.database.persistence.method.interceptor.SqlInterceptorAdapter;

import java.util.Arrays;
import java.util.List;

/**
 * lazy orm 方法操作工厂
 */
public class LazyOperationMethodFactory {

    /**
     * 创建默认 orm 操作对象
     * @param lazyOperationAttribute LazyOperationAttribute 配置
     * @return List<LazyOperationMethod>
     */
    public static List<LazyOperationMethod> createDefaultLazyOperationMethod(LazyOperationAttribute lazyOperationAttribute) {
        SqlInterceptorAdapter defaultSqlInterceptorAdapter = SqlInterceptorAdapterFactory.createDefaultSqlInterceptorAdapter();
        LazyOperationParameter lazyOperationParameter =
                new LazyOperationParameter()
                        .setLazyOperationAttribute(lazyOperationAttribute)
                        .setSqlInterceptorAdapter(defaultSqlInterceptorAdapter);

        return Arrays.asList(
                new LazyOperationMethodCreateTable(lazyOperationParameter),
                new LazyOperationMethodCreateTableEndpoint(lazyOperationParameter),
                new LazyOperationMethodExecute(lazyOperationParameter),
                new LazyOperationMethodExecutePage(lazyOperationParameter),
                new LazyOperationMethodExecuteOne(lazyOperationParameter),
                new LazyOperationMethodExecuteSQL(lazyOperationParameter),
                new LazyOperationMethodExecuteSQLForBean(lazyOperationParameter),
                new LazyOperationMethodInsert(lazyOperationParameter),
                new LazyOperationMethodSaveOrUpdate(lazyOperationParameter),
                new LazyOperationMethodPage(lazyOperationParameter),
                new LazyOperationMethodPerfect(lazyOperationParameter),
                new LazyOperationMethodUpdateTable(lazyOperationParameter),
                new LazyOperationMethodUpdateTableEndpoint(lazyOperationParameter),
                new LazyOperationMethodUpsert(lazyOperationParameter),
                new LazyOperationMethodWeakInsert(lazyOperationParameter),
                new LazyOperationMethodWeakUpsert(lazyOperationParameter),
                new LazyOperationMethodUpsertRemoveNull(lazyOperationParameter),
                new LazyOperationMethodScriptRunner(lazyOperationParameter),
                new LazyOperationMethodStringScriptRunner(lazyOperationParameter)

        );
    }

    /**
     * 创建默认 orm 操作对象
     * @return List<LazyOperationMethod>
     */
    public static List<LazyOperationMethod> createDefaultLazyOperationMethod() {
        return createDefaultLazyOperationMethod(null);
    }

}